import { request } from '../utils/request.js'
import store from '../store'
import md5 from 'js-md5'
import { Toast, Jump } from '../utils/tools.js'
import { UserInfo,balance } from "@/api/Users.js"


//合伙人 当前数量
export async function hhrTotalCount(params) {
	try {
		let res = await request({
			url: '/Payment/hhrTotalCount',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}
//成为合伙人合伙人
export async function hhrApply(params) {
	try {
		params.paypassword = md5(params.paypassword);
		let res = await request({
			url: '/Payment/hhrApply',
			method: "post",
			params
		})
		if (res.success) {
			await UserInfo();
			await balance()
		}
		return res
	} catch (e) {
		return false
	}
}

//创建 充值 订单
export async function Recharge(params) {
	try {
		// params.paypassword = md5(params.paypassword);
		let res = await request({
			url: '/Payment/Recharge',
			method: "post",
			params
		})
		// if (res.success) {
		// 	await UserInfo()
		// }
		return res
	} catch (e) {
		return false
	}
}

// 开设分公司
export async function addCompay(data) {
	try {
		let res = await request({
			url: '/Payment/addCompay',
			method: "post",
			data
		})
		if (res.success) {
			await UserInfo()
			// await balance()
		}
		return res
	} catch (e) {
		return false
	}
}

// 公司信息查询
export async function mycompy(params) {
	try {
		const { success, msg, data, code } = await request({
			url: '/Payment/mycompy',
			method: "post",
			params
		})
		return { success, msg, data, code }
	} catch (e) {
		return false
	}
}